const {AMOUNT_IS_REQUIRED,AMOUNT_IS_ERROR}=require('../error/errorType')

const verifyRecharge=async(ctx,next)=>{
    let {amount}=ctx.request.body
    if(!amount){
        return ctx.app.emit('error',new Error(AMOUNT_IS_REQUIRED),ctx)
    }
    if(Number(amount)<0){
        return ctx.app.emit('error',new Error(AMOUNT_IS_ERROR),ctx)
    }

    ctx.amount=Number(amount)
    await next()
}

module.exports={
    verifyRecharge
}